-- undifferentiated_damage2
-- create by shuzy
-- 技能：无差别全体伤害，根据配置的数值
-- 目前支持如下配置：
-- 1、undifferentiated_damage2(1200)：对目标造成1200的魔法伤害

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 伤害
        local damage = para[1];

        -- 先对玩家造成伤害
        CombatM.receiveDamage(source, target, damage, skillId, extra);

        -- 4. 遍历所有的怪
        -- 总杀害
        local totalDamage = damage;
        for p = 1, GRID_SIZE do
            local grid = DungeonM.getGridByPos(p);
            local monster = grid.monster;

            repeat

                -- 是未死亡的怪物，排除自身
                if  not grid:isOpened() or
                    not monster or
                    grid.monster:isDead() or
                    monster == source then
                    break;
                end

                -- 增加命中动作
                if SkillM.getSequence(grid.monster) == nil then
                    SkillM.getSequenceList()[grid.monster] = CastSequence.create(source, grid.monster, skillId);
                end

                SkillM.getSequence(grid.monster):hit(source, grid.monster, skillId);
                CombatM.receiveDamage(source, monster, damage, skillId, extra);
                totalDamage = totalDamage + damage;

            until true;
        end

        -- 作用目标
        return target;
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        return desc;
    end,
};
